function validate(id, regex, min, max, result) {
    //Get what's validated
    var Validated = document.getElementById(id);

    //Check
    if (Validated.value.length < min)
        //document.getElementById(result).innerHTML = "Minimum length allowed is " + min + ".";
        document.getElementById(result).innerHTML = '<img src="imgsrc/cross.png" alt="">';
    else if (max > -1 && Validated.value.length > max)
        //document.getElementById(result).innerHTML = "Maximum length allowed is " + max + ".";
        document.getElementById(result).innerHTML = '<img src="imgsrc/cross.png" alt="">';
    else if (!regex.test(Validated.value))
        //document.getElementById(result).innerHTML = "Character not allowed.";
        document.getElementById(result).innerHTML = '<img src="imgsrc/cross.png" alt="">';
    else //document.getElementById(result).innerHTML = true;
        document.getElementById(result).innerHTML = '<img src="imgsrc/check.png" alt="">';
}
function confirmPassword(text1, text2, result) {
    //Check
    if (document.getElementById(text1).value == document.getElementById(text2).value)
        //document.getElementById(result).innerHTML = "";
            document.getElementById(result).innerHTML = '<img src="imgsrc/check.png" alt="">';
    else	document.getElementById(result).innerHTML = '<img src="imgsrc/cross.png" alt="">';
    return;
}
function validateform(id,name,user,pass,confirm,email){
    var valid = '<img src="imgsrc/check.png" alt="">';
    if(document.getElementById(name).innerHTML == valid &&
        document.getElementById(user).innerHTML == valid &&
        document.getElementById(pass).innerHTML == valid &&
        document.getElementById(confirm).innerHTML == valid &&
        document.getElementById(email).innerHTML == valid
            )
        return true;
    else
        {
        resultvalidate(id);
        return false;
        }
}
function resultvalidate(id){
    document.getElementById(id).innerHTML = '<div>Invalid field in form!!</div>';
}
